package com.example.dao;

import com.example.entity.Student;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
//@Repository
public interface StudentDao {

    @Select("select * from student")
    public List<Student> getAll();

    @Select("select * from student where job_number=#{jobNumber} and password=#{password}")
    public Student login(Student student);


    @Select("select * from student where id=#{id}")
    public Student getOne(int id);


    /**
     * 分页查询
     * @param currentPage  当前页
     * @param pageSize     当前页条数
     * @return
     */
    @Select("select * from student limit #{currentPage}, #{pageSize}")
    public List<Student> getPage(@Param("currentPage") int currentPage, @Param("pageSize")int pageSize);

    /**
     * 查询总记录数
     * @return
     */
    @Select("select count(*) from student")
    public int getTotalCount();


    @Insert("insert into student(stu_number,name,sex,age,ban_number,id_number,phone,image) " +
                       "values(#{stuNumber},#{name},#{sex},#{age},#{banNumber},#{idNumber},#{phone},#{image})")
    public int add(Student student);

    @Delete("delete from student where id=#{id}")
    public Boolean deleteById(@Param("id") Integer id);

    @Update("update student set stu_number=#{stuNumber},name=#{name},sex=#{sex}," +
            "age=#{age},id_number=#{idNumber},ban_number=#{banNumber},phone=#{phone},image=#{image} where id=#{id}")
    public int update(Student student) ;


}
